package com.fognl.core.net.handler;

import java.util.List;

/** A front-end for network operations. */
public interface NetworkHandler
{
	/** Start a request for data. The source of the data is specified by the <code>Request</code> through
	 * one of its implementations. The <code>ResponseListener</code> is notified when the information 
	 * retrieval is complete, fails, or is cancelled by a subsequent call to <code>cancelRequest()</code>. 
	 * @return A <code>RequestHandle</code> which can be used to inquire on the status of, or cancel, 
	 * a pending request.
	 * @throws NetworkHandlerException if an error occurs.
	 */
	RequestHandle startRequest(Request request, ResponseListener listener) throws NetworkHandlerException;
	
	/**
	 * Cancel the request associated with the specified requestHandle.
	 */
	NetworkHandler cancelRequest(RequestHandle handle) throws NetworkHandlerException;
	
	/** Return a list of pending requests. */
	List<RequestHandle> getPendingRequests();
}
